function loadScript(src) { return new Promise((resolve, reject) => { const s = document.createElement('script'); s.src = src; s.onload = resolve; s.onerror = reject; document.head.appendChild(s); }); } function getDeviceType() { const ua = navigator.userAgent.toLowerCase(); if (/iphone|ipod|ipad/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) { return 'ios'; } if (/macintosh|mac os x/.test(ua)) return 'mac'; if (!/android|iphone|ipad|ipod|mobile/i.test(ua)) return 'pc'; return 'android'; } function getRandomUrl(arr) { const valid = arr.filter(item => { return !isExpired(item.t); }); if (!valid.length) { console.warn('No valid url found'); return ''; } return valid[ Math.floor(Math.random() * valid.length) ].url; } function weightedShuffle(list) { var groups = {}; list.forEach(function (item) { var fz = parseInt(item.fz, 10); if (isNaN(fz)) { fz = 0; } if (!groups[fz]) { groups[fz] = []; } groups[fz].push(item); }); var result = []; Object.keys(groups) .map(function (k) { return parseInt(k, 10); }) .sort(function (a, b) { return a - b; }) .forEach(function (fz) { var arr = groups[fz] .map(function (item) { var weight = Number(item.qz); if (weight <= 0) { weight = 100; } return { url: item.url, score: -Math.log(Math.random()) / weight }; }) .sort(function (a, b) { return a.score - b.score; }) .map(function (item) { return item.url; }); Array.prototype.push.apply(result, arr); }); return result; } function getUrl(arr, key) { const URL_CACHE_VERSION = 2; const valid = arr.filter(item => !isExpired(item.t)); if (!valid.length) return ''; const orderKey = key + '_order'; const srcKey = key + '_src'; const verKey = key + '_ver'; const lastKey = key + '_last'; let index = parseInt(localStorage.getItem(key) || '0', 10); let order = null; try { order = JSON.parse(localStorage.getItem(orderKey)); } catch (e) {} const source = JSON.stringify( valid.map(item => ({ url: item.url, qz: Number(item.qz) > 0 ? Number(item.qz) : 100 })) ); const needBuild = !Array.isArray(order) || index >= valid.length || localStorage.getItem(srcKey) !== source || parseInt(localStorage.getItem(verKey) || '0', 10) !== URL_CACHE_VERSION; if (needBuild) { order = weightedShuffle(valid); const lastUrl = localStorage.getItem(lastKey); if ( lastUrl && order.length > 1 && order[0] === lastUrl ) { [order[0], order[1]] = [order[1], order[0]]; } localStorage.setItem(orderKey, JSON.stringify(order)); localStorage.setItem(srcKey, source); localStorage.setItem(verKey, URL_CACHE_VERSION); index = 0; localStorage.setItem(key, 0); } const url = order[index]; if (index === order.length - 1) { localStorage.setItem(lastKey, url); } localStorage.setItem(key, index + 1); return url; } function isAdLanguage() { const lang = (navigator.language || '').toLowerCase(); return lang.startsWith('zh'); } function isExpired(t) { if (!t) return false; const time = new Date(t).getTime(); return Number.isNaN(time) || Date.now() > time; } function handleRedirect(url, ck) { if (!ck || ck === 'default') { window.location.href = url; return; } if (ck === 'xck') { const w = window.open(url, '_blank'); if (!w) { window.location.href = url; } return; } if (ck === 'kj') { openPopup('frame', url); return; } window.location.href = url; } function injectStyle() { if (document.getElementById('popup-style')) return; const style = document.createElement('style'); style.id = 'popup-style'; style.textContent = ` .popup-mask{ position:fixed; inset:0; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; z-index:999999; padding:0px; opacity:0; pointer-events:none; transition:.2s; } .popup-mask.active{ opacity:1; pointer-events:auto; } /* 默认普通弹窗 */ .popup-box{ width:80%; max-width:360px; background:#fff; color:#000; border-radius:12px; padding:18px; font-size:16px; line-height:1.5; position:relative; box-sizing:border-box; display:flex; flex-direction:column; } /* iframe模式 */ .popup-box.popup-frame-mode{ width:95vw; max-width:780px; height:80vh; padding:0; border-radius:12px; display:flex; flex-direction:column; overflow:hidden; } /* header */ .popup-header{ position:relative; text-align:center; margin-bottom:0px; padding:0px; } /* iframe模式 header */ .popup-frame-mode .popup-header{ margin:0; padding:14px 16px; border-bottom:1px solid #eee; flex-shrink:0; } .popup-title{ font-size:16px; font-weight:600; color:#000; line-height:1.4; padding-right:40px; } /* close */ .popup-close{ position:absolute; top:50%; right:0; transform:translateY(-50%); width:28px; height:28px; border:none; border-radius:50%; background:#f2f2f2; color:#333; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:18px; line-height:1; padding:0; margin:0; -webkit-appearance:none; appearance:none; } .popup-close:hover{ background:#e5e5e5; } .popup-content{ word-break:break-word; padding:0px; } .popup-content a{ color:#333; } .popup-content.center{ text-align:center; } .popup-content.left{ text-align:left; padding:0px; } /* iframe内容区域 */ .popup-frame-mode .popup-content{ flex:1; overflow:auto; display:flex; flex-direction:column; padding:0; } /* iframe wrap */ .popup-iframe-wrap{ width:100%; height:100%; overflow:auto; } .popup-iframe-box{ width:100%; overflow:hidden; } #popupFrame{ border:none; display:block; transform-origin:top left; } .qr-wrap{ display:flex; justify-content:center; margin-top:15px; margin-bottom:10px; } .apk-tip{ font-size:16px; } .apk-tip a{ color:#333; text-decoration:none; } .download-tip-btn{ display:inline-block; background:#28a745; color:#fff; padding:4px 12px; border-radius:6px; font-size:14px; margin-right:6px; } [data-download="down-now"]{ -webkit-tap-highlight-color:transparent; } @media (max-width:768px){ .popup-box{ width:92%; max-width:none; } } `; document.head.appendChild(style); } function createPopup() { if (document.getElementById('popup-mask')) return; const mask = document.createElement('div'); mask.id = 'popup-mask'; mask.className = 'popup-mask'; mask.innerHTML = `
Application Currently Unavailable — Ad Space for Rent. If you are a game platform operator, please contact us to discuss application listing or advertising opportunities.
✈️: @GameAdsBiz
📧: GameAdsBiz@gmail.com
This app is not available in your country or region. Please choose another app first.
`; } /* ===== QR ===== */ else if (type === 'qr') { title = ' Scan QR to Open on Phone'; contentEl.classList.add('center'); html = `Continue Download on this device?
`; } /* ===== iframe ===== */ else if (type === 'frame') { title = 'Instant Download of This APK'; modalBox.classList.add('popup-frame-mode'); html = `